// Thud - a dynamic object-oriented language
// Copyright (C) 2009,2010 David H. Hovemeyer <david.hovemeyer@gmail.com>

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

/*
 * IClassVisitor.h
 *
 *  Created on: Dec 6, 2009
 *      Author: dhovemey
 */

#ifndef ICLASSVISITOR_H_
#define ICLASSVISITOR_H_

#include <cstdint>
#include "vm/Opcode.h"
#include "vm/IConstantVisitor.h"
class Class;
class ConstantPool;
class ConstantString;
class ConstantSymbol;
class ConstantInt32;
class ConstantClass;
class Field;
class Method;

/**
 * Visitor for the various features of a Class.
 */
class IClassVisitor : public IConstantVisitor {
private:
	IClassVisitor(const IClassVisitor &);
	IClassVisitor& operator=(const IClassVisitor &);

public:
	IClassVisitor();
	virtual ~IClassVisitor();

	/**
	 * Visit given Class.
	 */
	virtual void visitClass(Class *cls) = 0;

	/**
	 * Visit given ConstantPool.
	 */
	virtual void visitConstantPool(ConstantPool *cp) = 0;

	/**
	 * Visit given Field.
	 */
	virtual void visitField(Field *field) = 0;

	/**
	 * Visit given Method.
	 */
	virtual void visitMethod(Method *method) = 0;

	/**
	 * Visit given instruction.
	 * @param offset bytecode offset of the instruction
	 * @param opcode instruction Opcode
	 */
	virtual void visitInstruction(uint16_t offset, Opcode opcode) = 0;

	/**
	 * Visit given instruction.
	 * @param offset bytecode offset of the instruction
	 * @param opcode instruction Opcode
	 * @param cpIndex constant pool index of constant referenced by the instruction
	 */
	virtual void visitCPInstruction(uint16_t offset, Opcode opcode, uint16_t cpIndex) = 0;

	/**
	 * Visit given instruction.
	 * @param offset bytecode offset of the instruction
	 * @param opcode instruction Opcode
	 * @param i8     a signed 8-bit integer constant referenced by the instruction
	 */
	virtual void visitI8Instruction(uint16_t offset, Opcode opcode, int8_t i8) = 0;

	/**
	 * Visit given instruction.
	 * @param offset bytecode offset of the instruction
	 * @param opcode instruction Opcode
	 * @param cpIndex constant pool index of constant referenced by the instruction
	 * @param i8     a signed 8-bit integer constant referenced by the instruction
	 */
	virtual void visitCPI8Instruction(uint16_t offset, Opcode opcode, uint16_t cpIndex, int8_t i8) = 0;

	/**
	 * Visit given branch instruction.
	 * @param offset bytecode offset of the instruction
	 * @param opcode instruction Opcode
	 * @param branchOffset bytecode offset of instruction targeted by the branch
	 */
	virtual void visitBranchInstruction(uint16_t offset, Opcode opcode, uint16_t branchOffset) = 0;
};

#endif /* ICLASSVISITOR_H_ */
